package com.grudesign.stutrip.controller;


import com.grudesign.stutrip.common.ReturnInfo;
import com.grudesign.stutrip.entity.Vo.contentMsg;
import com.grudesign.stutrip.entity.Vo.uerMsgFrontVo;
import com.grudesign.stutrip.service.UserMsgService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 用户留言表 前端控制器
 * </p>
 *
 * @author wx
 * @since 2022-05-09
 */
@RestController
@RequestMapping("/userMsg")
public class UserMsgController {

    @Autowired
    private UserMsgService userMsgService;

    @PostMapping("/queryMsg/{cur}/{next}")
    public Object getMsgInfo(@PathVariable("cur") long cur,
                             @PathVariable("next") long next,
                             @RequestBody(required = false) contentMsg conMsg) {
        Object obj = userMsgService.queryMsg(cur,next,conMsg);
        return obj;
    }

    @DeleteMapping("/delMsg/{id}")
    public Object delMsg(@PathVariable("id") String id){
        boolean isDel= userMsgService.removeById(id);
        return isDel?new ReturnInfo("200","ok"):new ReturnInfo("-1","error");
    }


    @PostMapping("/savaMsg")
    public Object saveMsg(@RequestBody uerMsgFrontVo msgVo){
        Object obj =  userMsgService.saveMsg(msgVo);
        return obj;
    }
}

